import java.util.Deque;
import java.util.LinkedList;

public class Myqueue {
    //用两个队列进行模拟实现一个栈；
    public Deque<Integer> deque1;
    public Deque<Integer> deque2;
    public Myqueue(){
        deque1=new LinkedList<>();
        deque2=new LinkedList<>();
    }
    //1.进行判断这个栈是否为空；
    public boolean empty(){
        return deque1.isEmpty()&& deque2.isEmpty();
    }
    //2.入栈操作；
    public void push(int val){
        deque1.push(val);
    }
    //3.出栈操作
    public int pop(){
        if(empty()){
            return -1;
        }
        if(deque2.isEmpty()) {
            while (!deque1.isEmpty()) {
                deque2.push(deque1.pop());
            }
        }
            return deque2.pop();

    }
    //4.进行查看栈顶元素；
    public int peek(){
        if(empty()){
            return -1;
        }
        if(deque2.isEmpty()) {
            while (!deque1.isEmpty()) {
                deque2.push(deque1.pop());
            }
        }
        return deque2.peek();
    }
}
